package mapeditor.mappanel.old;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;

import javax.swing.JScrollBar;

import mapeditor.itemselectpanel.ItemSelectionPanel;

public class ListViewScrollBar extends JScrollBar
{

	private double	ratioToPaintAt;

	public ListViewScrollBar() {
		super( );
		ratioToPaintAt = -1;
		addAdjustmentListener( new MapViewScrollBarChangeListener( ) );
	}

	public void paint( Graphics g )
	{
		super.paint( g );
		if ( ratioToPaintAt >= 0 ) {
			Color prev = g.getColor( );
			g.setColor( Color.BLUE );
			int height = 17 + (int) (ratioToPaintAt
					* this.getSize( ).getHeight( ) * .96);
			g.fillRect( 0 , height , this.getWidth( ) , 3 );
			g.setColor( prev );
		}
	}

	public void setRatio( double ratio )
	{
		ratioToPaintAt = ratio;
		repaint( );
	}

	public class MapViewScrollBarChangeListener implements AdjustmentListener
	{

		@Override
		public void adjustmentValueChanged( AdjustmentEvent e )
		{

		}

	}
}
